#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int maxn = 2e5+5;
int m, n, k;
int arr_l[maxn];
int arr_r[maxn];


bool check(int cnt){
	for (int i=0;i<=n;i++) {
		if (cnt -i >= 0 && cnt-i <= m) {
			if (arr_l[i] + arr_r[cnt-i] <= k) {
				return true;
			}
		}
	}
	return false;
}


void solve(){
	cin >> n >> m >> k;
	for (int i=1;i<=n;i++) {
		cin >> arr_l[i];
	}
	
	for (int j=1;j<=m;j++) {
		cin >> arr_r[j];
	}
	// 计算前缀和
	for (int i=1;i<=n;i++) {
		arr_l[i] = arr_l[i-1] + arr_l[i];
	} 
	
	for (int j=1;j<=m;j++) {
		arr_r[j] = arr_r[j-1] + arr_r[j];
	}
	
	int l=0;
	int r = m+n+1;
	while(l < r-1){
		int m = ((r-l)>>1) + l;
		if (check(m)) {
			l=m;
		} else {
			r=m;
		}
	}
	cout << l << '\n';
}



signed main(){
	int t;
	t=1;
	while(t--){
		//TODO
		solve();
	}
	return 0;
}
